import popupWindowWrapper from "./popupWindowWrapper.js";
import {buildVueComputedListFromRef} from "../utils.js";

export default {
    components: {
        popupWindowWrapper
    },
    setup() {
        const popup = Vue.ref(null);
        const titleText = Vue.ref("提示");
        const infoText = Vue.ref("提示");

        function show(infoText_ = "提示", titleText_ = "提示") {
            popup.value.show();
            titleText.value = titleText_;
            infoText.value = infoText_;
        }

        function hide() {
            popup.value.hide();
        }

        const [onConfirm, onCancel,
            confirmBtnText, cancelBtnText,
            widthInParent, heightInParent] =
            buildVueComputedListFromRef(popup, ['onConfirm', 'onCancel',
                'confirmBtnText', 'cancelBtnText',
                'widthInParent', 'heightInParent']);
        // console.log("popup info setup finish");
        // Vue.onMounted(() => {
        //     console.log("popup info onMounted");
        // })
        return {
            show, infoText, titleText, popup,
            onConfirm, onCancel, hide,
            confirmBtnText, cancelBtnText,
            widthInParent, heightInParent,
        };
    },
    template: `
<popupWindowWrapper ref="popup">
    <div class="popup-info-content">
        <p class="my-font" style="font-size: 30px;">
            {{ titleText }}
        </p>
        <div class="my-font" style="font-size: 22px;">
            {{ infoText }}
        </div>
    </div>
</popupWindowWrapper>`
}